package view.component.weapon.bug_stick
{
	import enums.main.UISize;
	
	import feathers.controls.Label;
	import feathers.data.ListCollection;
	
	import model.vo.weapon.BugStickBugVo;
	
	import view.component.BaseSCListView;
	import view.render.weapon.BugStickBugItem;
	
	/**
	 * 不同培养形式的猎虫列表界面基类
	 * @author £iang
	 * 
	 */	
	public class BaseBugTypeView extends BaseSCListView
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** 猎虫名标题 */
		public var nameTitle:Label;
		/** 升级点标题 */
		public var pointTitle:Label;
		/** 发动技能点数标题 */
		public var skillPointTitle:Label;
		/** 发动技能标题 */
		public var skillTitle:Label;
		/** 升级素材标题 */
		public var itemTitle:Label;
		/** 示意图标题 */
		public var imageTitle:Label;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 初始化函数 
		 * 
		 */		
		override protected function initialize():void
		{ 
			_itemH = UISize.BUG_ITEM_H * this.dpiScale;
			_listH = UISize.MAIN_H - 
				( UISize.MONSTER_TAB_AREA_H * 3 + 
					UISize.LIST_TITLE_H - 20 ) * this.dpiScale;
			_scrollerMaxPage = 3;
			_firstName = "等级";
			super.initialize();
		}
		
		override protected function initializeOther():void
		{
			super.initializeOther();
			nameTitle = new Label();
			nameTitle.text = "猎虫名";
			scollerContainer.addChild( nameTitle );

			pointTitle = new Label();
			pointTitle.text = "升级pt";
			scollerContainer.addChild( pointTitle );
			
			skillPointTitle = new Label();
			skillPointTitle.text = "Pw/St/Sp";
			scollerContainer.addChild( skillPointTitle );
			
			skillTitle = new Label();
			skillTitle.text = "发动技能";
			scollerContainer.addChild( skillTitle );
			
			itemTitle = new Label();
			itemTitle.text = "升级素材";
			scollerContainer.addChild( itemTitle );
			
			imageTitle = new Label();
			imageTitle.text = "示意图(打/切)";
			scollerContainer.addChild( imageTitle );
		}
		
		/**
		 * 绘制函数 
		 * 
		 */		
		override protected function draw():void
		{
			var labelY:Number = ( UISize.LIST_TITLE_H - 
				43 ) / 2 * this.dpiScale;
			var leftPadding:Number = UISize.TITLE_PADDING_LEFT * this.dpiScale;
			var firstLabelFullW:Number;
			
			firstTitle.y = labelY;
			firstTitle.x = leftPadding;
			firstLabelFullW = UISize.MAIN_W * 0.2;
			firstTitle.width = firstLabelFullW - leftPadding;
			
			scollerContainer.x = firstLabelFullW;
			scollerContainer.width = UISize.MAIN_W - firstLabelFullW;
			scollerContainer.height = UISize.LIST_TITLE_H;
			
			nameTitle.y = labelY;
			nameTitle.x = 0;
			nameTitle.width  = UISize.MAIN_W * 0.6;
			
			pointTitle.y = labelY;
			pointTitle.x = UISize.MAIN_W * 0.6;
			pointTitle.width  = UISize.MAIN_W * 0.2;
			
			skillPointTitle.y = labelY;
			skillPointTitle.x = UISize.MAIN_W * 0.8;
			skillPointTitle.width  = UISize.MAIN_W * 0.4;
			
			skillTitle.y = labelY;
			skillTitle.x = UISize.MAIN_W * 1.2;
			skillTitle.width  = UISize.MAIN_W * 0.4;
			
			itemTitle.y = labelY;
			itemTitle.x = UISize.MAIN_W * 1.6;
			itemTitle.width  = UISize.MAIN_W * 0.8;
			
			imageTitle.y = labelY;
			imageTitle.x = UISize.MAIN_W * 2.4;
			imageTitle.width  = UISize.MAIN_W * 0.8;
			
			var buttonY:Number = ( UISize.LIST_TITLE_H * this.dpiScale - leftButton.height ) / 2;
			
			leftButton.x = firstLabelFullW - leftButton.width;
			leftButton.y = buttonY;
			
			rightButton.x = UISize.MAIN_W - leftButton.width;
			rightButton.y = buttonY;
			
			list.y = UISize.LIST_TITLE_H * this.dpiScale;
		}
		
		/**
		 * 设置列表数据 
		 * @param dataVec 数据
		 * 
		 */		
		public function setListData( dataVec:Vector.<BugStickBugVo> ):void
		{
			var i:int;
			var len:int = dataVec.length;
			
			_listData = new ListCollection([]);
			
			for( i = 0; i < len; i++)
			{
				var item:BugStickBugItem = new BugStickBugItem();
				var tmpData:BugStickBugVo = dataVec[ i ] as BugStickBugVo;
				
				item.setData( tmpData );
				_listData.push( { item:item, itemData:tmpData } );
			}
			
			list.dataProvider = _listData;
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 析构滚动条容器中的标签 
		 * 
		 */		
		protected override function disposeAnythingInContainer():void
		{
			disposeLabels( [
				"name", "point",
				"skillPoint", "skill",
				"item", "image"
			] );
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function BaseBugTypeView()
		{
			super();
		}
	}
}